<template>
    <div>
        <Modal v-model="modal.add" title="添加" :mask-closable="false" @on-visible-change="changeModalVisibleResetForm('addForm', $event)" width="1020">
            <Form ref="addForm" :model="form" :label-width="120" :rules="validateRules">
                <Row>
	<i-col span="12">
	<FormItem label="用户编号" prop="userId">
	<InputNumber v-model="form.userId" placeholder="请输入用户编号" style="width: 100%;"/>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="类目编号" prop="categoryId">
	<InputNumber v-model="form.categoryId" placeholder="请输入类目编号" style="width: 100%;"/>
</FormItem>
	</i-col>

	<i-col span="12">
		<FormItem label="主体类型" prop="subjectType">
		    
		        <Select v-model="form.subjectType" placeholder="主体类型" filterable clearable>
		          <Option
		            v-for="(option, index) in subjectTypeSelect"
		            :value="option.value"
		            :key="index"
		          >{{option.displayValue}}</Option>
		        </Select>
		    
		</FormItem>
	
	</i-col><i-col span="12">
	<FormItem label="店铺Logo" prop="logo">
	<Input v-model="form.logo" placeholder="请输入店铺Logo" clearable/>
</FormItem>
	</i-col>

	<i-col span="12">
	<FormItem label="店铺标题" prop="title">
	<Input v-model="form.title" placeholder="请输入店铺标题" clearable/>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="店铺简介" prop="intro">
	<Input v-model="form.intro" placeholder="请输入店铺简介" clearable/>
</FormItem>
	</i-col>

	<i-col span="12">
	<FormItem label="店铺等级" prop="level">
	    
	        <Select v-model="form.level" placeholder="店铺等级" filterable clearable>
	          <Option
	            v-for="(option, index) in levelSelect"
	            :value="option.value"
	            :key="index"
	          >{{option.displayValue}}</Option>
	        </Select>
	    
	</FormItem>
	</i-col><i-col span="12">
	<FormItem label="审核状态" prop="checkStatus">
	    
	        <Select v-model="form.checkStatus" placeholder="审核状态" filterable clearable>
	          <Option
	            v-for="(option, index) in checkStatusSelect"
	            :value="option.value"
	            :key="index"
	          >{{option.displayValue}}</Option>
	        </Select>
	    
	</FormItem>
	
	</i-col>

	<i-col span="12">
	<FormItem label="审核描述" prop="checkDescription">
	<Input v-model="form.checkDescription" placeholder="请输入审核描述" clearable/>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="审核人编号" prop="checkedUserId">
	<InputNumber v-model="form.checkedUserId" placeholder="请输入审核人编号" style="width: 100%;"/>
</FormItem>
	</i-col>

	<i-col span="12">
	<FormItem label="审核时间" prop="checkedTime">
	<DatePicker @on-change="form.checkedTime=$event" :value="form.checkedTime" placeholder="请输入审核时间" type="datetime" format="yyyy-MM-dd HH:mm:ss" style="width: 100%;" clearable></DatePicker>
</FormItem>
	</i-col>
</Row>

            </Form>
            <div slot="footer">
                <Button type="text" size="large" @click="resetFormCancelModal('addForm', 'add')">取消</Button>
                <Button type="primary" size="large" @click="add" :loading="loading.add">添加</Button>
            </div>
        </Modal>
        <Modal v-model="modal.edit" title="修改" :mask-closable="false" @on-visible-change="changeModalVisibleResetForm('editForm', $event)" width="1020">
            <Form ref="editForm" :model="form" :label-width="120" :rules="validateRules">
                <Row>
	<i-col span="12">
	<FormItem label="用户编号" prop="userId">
	<InputNumber v-model="form.userId" placeholder="请输入用户编号" style="width: 100%;"/>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="类目编号" prop="categoryId">
	<InputNumber v-model="form.categoryId" placeholder="请输入类目编号" style="width: 100%;"/>
</FormItem>
	</i-col>

	<i-col span="12">
	<FormItem label="主体类型" prop="subjectType">
	    
	        <Select v-model="form.subjectType" placeholder="主体类型" filterable clearable>
	          <Option
	            v-for="(option, index) in subjectTypeSelect"
	            :value="option.value"
	            :key="index"
	          >{{option.displayValue}}</Option>
	        </Select>
	    
	</FormItem>
	</i-col><i-col span="12">
	<FormItem label="店铺Logo" prop="logo">
	<Input v-model="form.logo" placeholder="请输入店铺Logo" clearable/>
</FormItem>
	</i-col>

	<i-col span="12">
	<FormItem label="店铺标题" prop="title">
	<Input v-model="form.title" placeholder="请输入店铺标题" clearable/>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="店铺简介" prop="intro">
	<Input v-model="form.intro" placeholder="请输入店铺简介" clearable/>
</FormItem>
	</i-col>

	<i-col span="12">
		<FormItem label="店铺等级" prop="level">
		    
		        <Select v-model="form.level" placeholder="店铺等级" filterable clearable>
		          <Option
		            v-for="(option, index) in levelSelect"
		            :value="option.value"
		            :key="index"
		          >{{option.displayValue}}</Option>
		        </Select>
		    
		</FormItem>
	
	</i-col><i-col span="12">
	<FormItem label="审核状态" prop="checkStatus">
	    
	        <Select v-model="form.checkStatus" placeholder="审核状态" filterable clearable>
	          <Option
	            v-for="(option, index) in checkStatusSelect"
	            :value="option.value"
	            :key="index"
	          >{{option.displayValue}}</Option>
	        </Select>
	    
	</FormItem>
	</i-col>

	<i-col span="12">
	<FormItem label="审核描述" prop="checkDescription">
	<Input v-model="form.checkDescription" placeholder="请输入审核描述" clearable/>
</FormItem>
	</i-col><i-col span="12">
	<FormItem label="审核人编号" prop="checkedUserId">
	<InputNumber v-model="form.checkedUserId" placeholder="请输入审核人编号" style="width: 100%;"/>
</FormItem>
	</i-col>

	<i-col span="12">
	<FormItem label="审核时间" prop="checkedTime">
	<DatePicker @on-change="form.checkedTime=$event" :value="form.checkedTime" placeholder="请输入审核时间" type="datetime" format="yyyy-MM-dd HH:mm:ss" style="width: 100%;" clearable></DatePicker>
</FormItem>
	</i-col>
</Row>

            </Form>
            <div slot="footer">
                <Button type="text" size="large" @click="resetFormCancelModal('editForm', 'edit')">取消</Button>
                <Button type="primary" size="large" @click="edit" :loading="loading.edit">修改</Button>
            </div>
        </Modal>
    </div>
</template>

<script>
	import * as utils from '@/api/utils-v2'
	import * as ResponseStatus from '@/api/response-status'
    export default {
        name: 'GoodsShopAddEdit',
        data() {
            return {
                modal: {
                    add: false,
                    edit: false
                },
				dataDictCodes: ['SHOP_SUBJECT_TYPE','SHOP_LEVEL','SHOP_CHECK_STATUS'],
				dataDictItems: {},
				subjectTypeSelect:[],
				levelSelect:[],
				checkStatusSelect:[],
                loading: {
                    add: false,
                    edit: false
                },
                urls: {
                    addUrl: '/goods-shop/admin/save',
                    batchAddUrl: '/goods-shop/admin/batch-save',
                    editUrl: '/goods-shop/admin/update',
                    batchEditUrl: '/goods-shop/admin/batch-update'
                },
                form: {
                    id: null,
userId: null,
categoryId: null,
subjectType: null,
logo: null,
title: null,
intro: null,
level: null,
checkStatus: null,
checkDescription: null,
checkedUserId: null,
checkedTime: null,


                },
                validateRules: {
                    userId: [
{type: 'integer', required: true, message: '此项为必须项', trigger: 'blur, change'}
],
categoryId: [
{type: 'integer', required: true, message: '此项为必须项', trigger: 'blur, change'}
],
subjectType: [
{type: 'integer', required: true, message: '此项为必须项', trigger: 'blur, change'}
],
logo: [
{type: 'string', min: 1, max: 500, message: '必须1-500个字符', trigger: 'blur'}
],
title: [
{type: 'string', required: true, message: '此项为必须项', trigger: 'blur'},
{type: 'string', min: 1, max: 50, message: '必须1-50个字符', trigger: 'blur'}
],
intro: [
{type: 'string', required: true, message: '此项为必须项', trigger: 'blur'},
{type: 'string', min: 1, max: 255, message: '必须1-255个字符', trigger: 'blur'}
],
checkDescription: [
{type: 'string', min: 1, max: 255, message: '必须1-255个字符', trigger: 'blur'}
],

                }
            }
        },
        computed: {},
        mounted() {
			            utils.getDataDict(this.dataDictCodes).then(response => {
			              if (response) {
			                this.dataDictItems = response
			                utils.getSelectDictItems(this, 'SHOP_SUBJECT_TYPE', 'subjectType', 'subjectTypeSelect')
							utils.getSelectDictItems(this, 'SHOP_LEVEL', 'level', 'levelSelect')
							utils.getSelectDictItems(this, 'SHOP_CHECK_STATUS', 'checkStatus', 'checkStatusSelect')
			              }
			            }).catch(error => {
			              console.log(error)
			            })
		},
        methods: {
            changeModalVisibleResetForm(formRef, visible) {
                if (!visible) {
					this.$refs[formRef].resetFields()
					this.form.id = null
                }
            },
            resetFormCancelModal(formRef, modal) {
                this.modal[modal] = false
			    this.$refs[formRef].resetFields()
				this.form.id = null
            },
            add() {
                this.$emit('add')
            },
            edit() {
                this.$emit('edit')
            }
        }
    }
</script>

<style>
</style>
